<script setup>
import {post} from "@/http";

const title = "全国计算机技术与软件专业技术资格（水平）考试"
import {User, Lock} from "@element-plus/icons-vue";
import {ref, reactive} from 'vue'
import {ElMessage} from "element-plus";
import router from "@/router";

let exam = reactive({'font-size': '30px', 'font-family': '宋体', 'color': 'green'})

function redBlue() {
  if (exam.color == 'green') {
    exam.color = 'skyblue';
  } else {
    exam.color = 'green';
  }
}

const username = ref("");
const pwd = ref("");
const login = () => {
  if (username.value == "" || username.value == null) {
    ElMessage.warning("请输入用户名")
  } else if (pwd.value == "" || pwd.value == null) {
    ElMessage.warning("请输入密码")
  } else {
    post('/registe/person', {username: username.value, pwd: pwd.value}, (msg) => {
      console.log('接收到后端的返回数据' + msg);
      ElMessage.success(msg)
      router.push("/home");
    }, (msg) => {
      ElMessage.warning(msg)
    })
  }
}
</script>
<template>
  <h3 v-text="title" :style="exam" @click="redBlue" style="top: 0px;text-align: center"></h3>
  <div id="layoo">
    <el-form id="biao">
      <el-divider style="margin-top: 30px">欢迎登录我们的系统</el-divider>
      <el-input type="text" placeholder="用户名/邮箱" v-model="username">
        <template #prefix>
          <el-icon>
            <User/>
          </el-icon>
        </template>
      </el-input>
      <el-input type="password" placeholder="密码" v-model="pwd">
        <template #prefix>
          <el-icon>
            <Lock/>
          </el-icon>
        </template>
      </el-input>
      <router-link to="/refiy">
        <el-button type="warning" round id="refiy">点击按钮进行验证</el-button>
      </router-link>

      <el-button type="success" round id="login" @click="login()">登录</el-button>
      <el-container style="padding:0px;position: relative">
        <router-link to="/regiset">
          <el-link type="info" class="textt" style="margin-left: 0px" @click="regiset">没有账号？去注册</el-link>
        </router-link>
        <el-link type="info" class="textt" style="right: 0px;position: absolute;"> 忘记密码?</el-link>
      </el-container>
    </el-form>
  </div>
</template>

<style scoped>
#biao {
  position: absolute;
  right: 0px;
  left: 0px;
  width: 100%;
  padding: 0px;
}

#layoo {
  margin: 0px;
  position: absolute;
  top: 230px;
  bottom: 0px;
  left: 0px;
  right: 0px;
  width: 100%;
  height: 100%;
}

#refiy, #login {
  width: 100%;
  margin-top: 10px;
}

#login {
  margin-left: 0px;
}

.textt {
  font-family: "楷体";
}

.textt:hover {
  color: red;
}

.tpic {
  background-color: lightskyblue;

}
</style>